Base = {}

function Base.new()
    local self = {a = 1}
    return self
end

Derived = {}

function Derived.new()
    local self = {}
    setmetatable(self,{__index=Base.new()})
    return self
end

num = 0
for i = 0, (1000000-1) do
   obj = Derived.new()
   num = num + obj.a
end

print(num)
